#封装请求方法
import  requests
class SendMenthod:
    @staticmethod
    def send_method(method,url,params=None,data=None,json=None):
        if method in ['get','post']:
            response =requests.request(method=method, url = url, params = params, headers = headers, data = data,
            json = json)
        else:
            response = None
            print('请求方法错误')

        reslut = {}
        if response is not None:
            reslut['status_code'] = response.status_code
            reslut['body'] = response.json()
            reslut['headers'] = response.headers
            return reslut
        else:
            return response

if __name__ == '__main__':
    url = 'http://47.108.206.100:8080/admin/login'
    body = {
        "username": "admin",
        "password": "macro123"
    }
    # print(SendMethod.send_method("post", url=url, data=body))
    print(SendMenthod.send_method("post", url=url, json=body))




